using System;
using System.Collections.Generic;
using System.Text;
using DAL;
using Entities;
using Utility;

namespace BUS
{
    public class tbDoanhnghiepBUS
    {
        public static void Insert(tbDoanhnghiep dn)
        {
            tbDoanhnghiepDAL dnDAL = new tbDoanhnghiepDAL();
            dnDAL.Insert(dn);
        }
        public static void Update(tbDoanhnghiep dn)
        {
            tbDoanhnghiepDAL dnDAL = new tbDoanhnghiepDAL();
            dnDAL.Update(dn);
        }
        public static void Delete(int iD)
        {
            tbDoanhnghiepDAL dnDAL = new tbDoanhnghiepDAL();
            dnDAL.Delete(iD);
        }
        public static tbDoanhnghiepCollection Get(string where, int pageindex, int pagesize, string orderby, string orderdirection, out int total)
        {
            tbDoanhnghiepDAL dnDAL = new tbDoanhnghiepDAL();
            return dnDAL.Get(where, pageindex, pagesize, orderby, orderdirection, out total);
        }
        public static tbDoanhnghiepCollection GetAll()
        {
            int total = 0;
            Criteria cri = new Criteria();
            tbDoanhnghiepDAL dnDAL = new tbDoanhnghiepDAL();
            return dnDAL.Get(cri.Criter, 0, 0, tbDoanhnghiepColumn.Madn.ToString(), OrderDirection.ASC.ToString(), out total);
        }
        public static tbDoanhnghiep GetByID(int iD)
        {
            int total = 0;
            Criteria cri = new Criteria();
            cri.add(Condition.AND, tbDoanhnghiepColumn.Madn.ToString(), Condition.EQUAL, iD);
            tbDoanhnghiepDAL dnDAL = new tbDoanhnghiepDAL();
            tbDoanhnghiepCollection tbdoanhnghiepCollection = dnDAL.Get(cri.Criter, 0, 0, tbDoanhnghiepColumn.Madn.ToString(), OrderDirection.ASC.ToString(), out total);
            if (tbdoanhnghiepCollection.Count > 0)
                return tbdoanhnghiepCollection[0];
            return null;
        }
        public static tbDoanhnghiepCollection GetLimited(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            tbDoanhnghiepDAL dnDAL = new tbDoanhnghiepDAL();
            return dnDAL.Get(cri.Criter, 1, number,
             tbDoanhnghiepColumn.Madn.ToString(), OrderDirection.DESC.ToString(), out total);
        }
        public static tbDoanhnghiepCollection GetPromotion(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            tbDoanhnghiepDAL dnDAL = new tbDoanhnghiepDAL();
            return dnDAL.Get(cri.Criter, 1, number,
               tbDoanhnghiepColumn.Madn.ToString(), OrderDirection.DESC.ToString(), out total);
        }
        public static tbDoanhnghiep GetByTendangnhap(string tdn)
        {
            tbDoanhnghiepDAL dnDAL = new tbDoanhnghiepDAL();
            return dnDAL.GetByTendangnhap(tdn);
        }
    }
}
